var vueFunctions = {}
window.vueFunctions = vueFunctions
export default {
  VUE_FUNCTION_NAME: 'vueFunctions',
  method (functionName, func) {
    return new Promise((resolve, reject) => {
      try {
        vueFunctions[functionName] = func
        resolve(vueFunctions)
      } catch (error) {
        reject(error)
      }
    })
  },
  do (functionName) {
    if (!vueFunctions[functionName]) {
      throw new Error('不存在 ' + functionName)
    }
    return new Promise((resolve, reject) => {
      try {
        vueFunctions[functionName]()
        resolve(vueFunctions)
      } catch (error) {
        reject(error)
      }
    })
  }
}
